package 猫和狗多态版;
//测试
public class AnimalDemo {
    public static void main(String[] args) {
        Animal a=new Cat();
        a.setName("1");
        a.setAge(20);
        System.out.println(a.getName()+","+a.getAge());
        a.eat();

        a=new Cat("11",20);
        System.out.println(a.getName()+","+a.getAge());
        a.eat();

        Animal a1=new Dog();
        a1.setName("2");
        a1.setAge(30);
        System.out.println(a1.getName()+","+a1.getAge());
        a1.eat();
        a1=new Dog("22",30);
        System.out.println(a1.getName()+","+a1.getAge());
        a1.eat();
    }
}
